﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace ZeroBug.EasyFlow.Core
{
    public class ThemeManager
    {
        private Dictionary<string, ResourceDictionary> _themes;
        public ThemeManager()
        {
            this._themes = new Dictionary<string, ResourceDictionary>();
        }
        public void RegisterTheme(string themeName, string assemblyPath, string resourcePath)
        {
            ResourceDictionary source = new ResourceDictionary();
            source.Source = new Uri($"/{assemblyPath};component/{resourcePath}", UriKind.Relative);
            _themes.Add(themeName, source);
        }
        public void ApplyTheme(string themeName)
        {
            foreach (var theme in _themes.Values)
            {
                Application.Current.Resources.MergedDictionaries.Remove(theme);
            }
            Application.Current.Resources.MergedDictionaries.Add(_themes[themeName]);
        }
    }
}
